<?php

class Skjb_Search_Xapian_Database_Writable extends Skjb_Search_Xapian_Database
{
    public $_cPtr = null;

    function __construct($path_or_other=null,$action=null) {
        switch (func_num_args()) {
        case 0: $r=new_WritableDatabase(); break;
        case 1: $r=new_WritableDatabase($path_or_other); break;
        default: $r=new_WritableDatabase($path_or_other,$action);
        }
        $this->_cPtr=$r;
    }

    function flush() {
        WritableDatabase_flush($this->_cPtr);
    }

    function begin_transaction($flushed=true) {
        WritableDatabase_begin_transaction($this->_cPtr,$flushed);
    }

    function commit_transaction() {
        WritableDatabase_commit_transaction($this->_cPtr);
    }

    function cancel_transaction() {
        WritableDatabase_cancel_transaction($this->_cPtr);
    }

    function add_document($document) {
        return WritableDatabase_add_document($this->_cPtr,$document);
    }

    function delete_document($did_or_unique_term) {
        WritableDatabase_delete_document($this->_cPtr,$did_or_unique_term);
    }

    function replace_document($did_or_unique_term,$document) {
        return WritableDatabase_replace_document($this->_cPtr,$did_or_unique_term,$document);
    }

    function add_spelling($word,$freqinc=1) {
        WritableDatabase_add_spelling($this->_cPtr,$word,$freqinc);
    }

    function remove_spelling($word,$freqdec=1) {
        WritableDatabase_remove_spelling($this->_cPtr,$word,$freqdec);
    }

    function add_synonym($term,$synonym) {
        WritableDatabase_add_synonym($this->_cPtr,$term,$synonym);
    }

    function remove_synonym($term,$synonym) {
        WritableDatabase_remove_synonym($this->_cPtr,$term,$synonym);
    }

    function clear_synonyms($term) {
        WritableDatabase_clear_synonyms($this->_cPtr,$term);
    }

    function set_metadata($key,$value) {
        WritableDatabase_set_metadata($this->_cPtr,$key,$value);
    }

    function get_description() {
        return WritableDatabase_get_description($this->_cPtr);
    }
}